package com.interfaces;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.entity.TaskRecordItem;

/**
 * @Title: TaskRecordItem.java
 * @Package com.interfaces
 * @author 孙梦楠
 * @date 2017年9月5日 下午3:06:07
 * @version V1.0.0
 */

public interface TaskRecordItemDao extends JpaRepository<TaskRecordItem, Integer> {

//	// 通过终端地址查
//	@Transactional
//	@Query(value = "SELECT tri FROM TaskRecordItem tri WHERE (tri.terminaladdress=?1) AND (tri.code=?2) "
//			+ "AND (tri.time > ?3 OR  ?3 IS NULL) AND (tri.time < ?4 OR ?4 IS NULL)")
//	public List<TaskRecordItem> findTaskrecorditemByTerminal(String terminaladdress, String code,String time1,String time2);

	// 通过表计地址查
	@Transactional
	@Query(value="SELECT * FROM e_task_record_item tri WHERE (tri.time > ?3 OR  ?3 IS NULL) AND (tri.time < ?4 OR ?4 IS NULL) "
			+ "AND (tri.meteraddress=?1) AND (tri.code=?2)  ORDER BY tri.time" ,nativeQuery=true)
	public List<TaskRecordItem> findTaskrecorditemByMeter(String meteraddress, String code,String time1,String time2);

}
